var searchv = new Vue({
	el: "#app",
	data:{
		s5,
		nav:[
			{item: '待发放'},
			{item: '已发完'}
		],
		isActive:0,
		cashcard:'',
		cashcard2:'',
		cashcardType:'',
		cashcardName:'',
		cashcardName2:'',
		buttonType:false,
		
	},
	computed:{
		
	},
	watch:{
		
	},
	created:function(){
		
	},
	mounted: function() {
		this.getCashcardType()
		this.cashcardList()
	},
	methods:{
		// 发放导航选项卡
		showNav(num){
			this.isActive = num;
		},
		// 获取所有卡券类型
		getCashcardType(){
			var that = this
			s5.initData({url:'/cashcard-type',type:'post'},(res)=>{
				var data = JSON.parse(res)
				that.cashcardType = data.data
				that.cashcardName = that.cashcardType[0]
			})
		},
		// 选取代金券类型按钮
		showButton(){
			this.buttonType =  !this.buttonType
		},
		// 获取所有卡券
		cashcardList(){
			var that = this
			s5.initData({url:'/cashcard-send',type:'post'},(res)=>{
				var data = JSON.parse(res)
				that.cashcard = data.data.list1
				that.cashcard2 = data.data.list2 
			})
		},
		// 根据代金券类型选择卡券
		chooseType(id,index){
			var that = this
			that.buttonType = false
			that.cashcardName = that.cashcardType[index]
			s5.initData({url:'/cashcard-send',type:'post',data:{cate_id:id}},(res)=>{
				var data = JSON.parse(res)
				that.cashcard = data.data.list1
				that.cashcard2 = data.data.list2
			})
		},
		// 点击跳转详情
		toCashcardDetail(id){
			window.location.href = "cashcard-send-detail.html?cate_id="+id
		},
		// 点击跳转历史记录
		toCashcardHistory(id){
			window.location.href = "cashcard-send-history.html?cate_id=" +id
		}
	}
})